package com.literature.search.core.entity.esindex;

import cn.easyes.annotation.IndexField;
import cn.easyes.annotation.IndexId;
import cn.easyes.annotation.IndexName;
import cn.easyes.annotation.rely.Analyzer;
import cn.easyes.annotation.rely.FieldStrategy;
import cn.easyes.annotation.rely.FieldType;
import cn.easyes.annotation.rely.IdType;
import com.literature.search.core.common.EsIndexConstant;
import com.literature.search.core.entity.EsPageObject;
import com.literature.search.core.entity.EsPicObject;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * @Author: DangKong
 * @Date: 2023/3/2 21:43
 * @Description: 存在ES中的父对象
 */



@Data
@ApiModel("存储在ES的文件对象")
@IndexName(value = EsIndexConstant.EN_INDEX_NAME)
public class ENEsFileObject implements Serializable {

    private static final long serialVersionUID = 1L;


    @IndexId(type = IdType.CUSTOMIZE)
    private String id;

    @IndexField(
            fieldType = FieldType.KEYWORD_TEXT,  //字段在es索引中的类型
            analyzer = Analyzer.IK_SMART,  //索引文档时用的分词器
            searchAnalyzer = Analyzer.IK_MAX_WORD, //查询分词器
            fieldData = true,  //是否设置可聚合
            strategy = FieldStrategy.NOT_NULL //字段策略 为null时不存储
    )
    @ApiModelProperty("文件名")
    private String fileName;

    @IndexField(
            fieldType = FieldType.KEYWORD,
            strategy = FieldStrategy.NOT_NULL //字段策略 为null时不存储
    )
    @ApiModelProperty("首页缩略图ID")
    private String thumbId;

    @ApiModelProperty("上传时间")
    @IndexField(
            fieldType = FieldType.DATE,
            dateFormat = "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis",
            strategy = FieldStrategy.NOT_NULL //字段策略 为null时不存储
    )
    private String uploadDate;

    @ApiModelProperty("上传人")
    @IndexField(
            fieldType = FieldType.KEYWORD_TEXT,
            analyzer = Analyzer.IK_SMART,
            searchAnalyzer = Analyzer.IK_MAX_WORD,
            strategy = FieldStrategy.NOT_NULL //字段策略 为null时不存储
    )
    private String uploadUser;

    @ApiModelProperty("点赞数")
    @IndexField(
            fieldType = FieldType.INTEGER,
            strategy = FieldStrategy.NOT_NULL //字段策略 为null时不存储
    )
    private Integer like;

    @ApiModelProperty("收藏数")
    @IndexField(
            fieldType = FieldType.INTEGER,
            strategy = FieldStrategy.NOT_NULL //字段策略 为null时不存储
    )
    private Integer collect;

    @ApiModelProperty("下载数")
    @IndexField(
            fieldType = FieldType.INTEGER,
            strategy = FieldStrategy.NOT_NULL //字段策略 为null时不存储
    )
    private Integer download;

    @ApiModelProperty("浏览数")
    @IndexField(
            fieldType = FieldType.INTEGER,
            strategy = FieldStrategy.NOT_NULL //字段策略 为null时不存储
    )
    private Integer view;

    @ApiModelProperty("每页文本内容嵌套类型")
    @IndexField(
            fieldType = FieldType.NESTED,
            fieldData = true,
            nestedClass = ENEsPageObject.class,
            strategy = FieldStrategy.NOT_NULL //字段策略 为null时不存储
    )
    private List<EsPageObject> pageContents;

    @ApiModelProperty("ES中每一个图片对象嵌套类型")
    @IndexField(
            fieldType = FieldType.NESTED,
            fieldData = true,
            nestedClass = ENEsPicObject.class,
            strategy = FieldStrategy.NOT_NULL //字段策略 为null时不存储
    )
    private List<EsPicObject> picContents;



    @ApiModelProperty("是否是英文文档")
    @IndexField(
            fieldType = FieldType.BOOLEAN,
            strategy = FieldStrategy.NOT_NULL //字段策略 为null时不存储
    )
    private Boolean isEnglish;

}